import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/7/6
 * Time:18:10
 **/
public class Main {
    /**
     * i am a student
     * student a am i
     * 句子逆序
     * 单词内部顺序正常
     * 除过大小写字母，其他的视为间隔符
     * 输出是，用一个空格做间隔
     * <p>
     * 单词倒排
     * 1. 预处理，间隔符全部替换为空格
     * 2. 按照空格符分割句子
     * 3. 逆序打印
     */
    public static boolean isAlpha(char ch) {
        return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z');
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str = sc.nextLine();
            //预处理：非字母字符转换为空格
            char[] arr = str.toCharArray();
            for (int i = 0; i < arr.length; i++) {
                if (!isAlpha(arr[i])) {
                    arr[i] = ' ';
                }
            }
            //按空格分割
            str = new String(arr);
            String[] strArr = str.split(" ");
            //逆序打印
            StringBuilder sb = new StringBuilder();
            for (int i = strArr.length - 1; i >= 0; i--) {
                sb.append(strArr[i] + " ");
            }
            System.out.println(sb.toString().trim());
        }
    }
}
